var webpack = require('webpack');
// var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
    debug: true,
    // devtool: '#cheap-module-eval-source-map',
    // devtool: '#cheap-module-source-map',//HMR7 no encode error,use this for hot replacement
    // devtool: '#eval-source-map',
    // devtool: '#source-map',//slow,no encode error
    // devtool: '#hidden-source-map',//slow inline
    // devtool: '#inline-source-map',//slow
    devtool: '#eval', //speed fasest

    // context: path.join(__dirname, 'app'),

    entry: [
        // 'webpack/hot/dev-server',        //HMR3
        // 'webpack-hot-middleware/client', //HMR4
        './app/js/app.main.js'
    ],

    output: {
        path: '/app',
        publicPath: '/',
        filename: 'js/app.bundle.js'
    },

    module: {
        preLoaders: [{
            test: /\.js$/,
            loader: "eslint",
            exclude: /(node_modules|lib)/
        }/*, {
            test: /.vue$/,
            loader: 'eslint',
            exclude: /node_modules/
        }*/],

        loaders: [{
            test: /\.vue$/,
            loader: 'vue',
            exclude: /node_modules/
        }, /*{
            test: /\.js$/,
            loaders: ['monkey-hot'],    //HMR5
            exclude: /node_modules/
        },*/ {
            test: /\.js$/,
            loader: 'babel',
            query: {
                cacheDirectory: true,
                compact: false,
                presets: ['es2015', 'stage-0'],
                plugins: ['transform-runtime']
            },
            exclude: /node_modules/
        }, {
            test: /\.(png|jpg|gif)$/,
            loader: 'url',
            query: {
                limit: 10*1024, //10KB
                name: 'img/[name].[ext]'
            },
            exclude: /node_modules/
        }/*, {
            test: /\.hbs$/,
            loader: 'handlebars-loader',
            exclude: /node_modules/
        }*/]
    },
    vue: {
        autoprefixer: {
            browsers: ['last 2 versions', 'iOS >= 7', 'Android >= 4']
        },
        loaders: {
            // sass: ExtractTextPlugin.extract(['css?minimize!sass'])
        }
    },

    plugins: [
        new webpack.optimize.OccurenceOrderPlugin(),
        // new webpack.HotModuleReplacementPlugin(),    //HMR6
        new webpack.NoErrorsPlugin(),
        // new ExtractTextPlugin("app.bundle.css"),
        //Provide global variables, used in the module without having to introduce
        new webpack.ProvidePlugin({
            VueTouch: "vue-touch",
            VueResource: "vue-resource",
        })
    ],

    resolve: {
        // modulesDirectories: [
        //     'node_modules'
        // ],
        //Configure an alias, reduces the reference path in the project
        alias: {
            // 'vue': __dirname+'/app/lib/vue/vue.js',
            // 'vue-touch': __dirname+'/node_modules/vue-touch'
        },
        // extensions: ['', '.js']
    }
};
